#ifndef __LOG4CPP_STATIC_H_
#define __LOG4CPP_STATIC_H_

#ifdef LOG4CPP_EXPORT
#define LOG4CPP_API __declspec(dllexport)
#else 
#define LOG4CPP_API __declspec(dllimport)
#endif

#include <map>
#include <string>
#include <memory>


#ifdef __cplusplus
extern "C"{
#endif
	namespace log4cpp {
		class Category;
		class PatternLayout;
		class RollingFileAppender;
		class OstreamAppender;
	}

	enum LogType
	{
		k_LOG_EXE = 0,
		k_LOG_DLL,
	};

    class LOG4CPP_API CLog4cpp{
	public:
		typedef struct stCategoryAppender
		{
			stCategoryAppender() : rolling_file_category_(NULL), rolling_file_appender_(NULL), stream_console_appender_(NULL), rolling_file_layout_(NULL){}
			stCategoryAppender(const std::string& name, log4cpp::RollingFileAppender *pA, log4cpp::PatternLayout *pL);
			stCategoryAppender(const std::string& name, log4cpp::RollingFileAppender *pA, log4cpp::OstreamAppender *pOA, log4cpp::PatternLayout *pL);

			log4cpp::Category *rolling_file_category_;
			log4cpp::RollingFileAppender *rolling_file_appender_;
			log4cpp::OstreamAppender* stream_console_appender_;
			log4cpp::PatternLayout *rolling_file_layout_;
		};
	public:
		CLog4cpp();
		CLog4cpp(bool Console);
		CLog4cpp(char *fileName, bool Console = false);
		void LogoutInfo(int log_type, const char* stringFormat, ...);
		void LogoutError(int log_type, const char* stringFormat, ...);
		void LogoutWarn(int log_type, const char* stringFormat, ...);
		void LogoutDebug(int log_type, const char* stringFormat, ...);

		void SetFileName(const std::string stringFileName);

    private:
		void initial(void* callerAddress);
		void Log4cppConfig();

	private:
		CLog4cpp(const CLog4cpp&);
		CLog4cpp& operator =(const CLog4cpp&);
	private:
		std::_Mutex m_log_writer_mutex;
		log4cpp::Category *m_log_writer_;
		static std::map<std::string, std::shared_ptr<stCategoryAppender> > map_logfile_appender_;
		std::string strFileName;
		bool isConsole_;
    };

#ifdef __cplusplus
};
#endif

#endif